unit FileSyncApp;

{$mode ObjFPC}{$H+}

interface

uses
  Classes, SysUtils, DaemonApp, FileSyncDeamon;


Type

  { TFileSyncApplication }

  TFileSyncApplication = class(TCustomDaemonApplication)
  protected
    //Procedure DoRun; override;
    Procedure OnConsoleRun(Sender: TObject);
  Public
    //Constructor Create(AOwner : TComponent); override;
    procedure ShowHelp; override;
  end;

implementation

{ TFileSyncApplication }

//procedure TFileSyncApplication.DoRun;
//begin
//  if (ParamCount = 2) and ((HasOption('e','encode')) or (FindCmdLineSwitch ('encode',['/'],True))) then
//    OnRun := @OnConsoleRun
//  else
//    OnRun := nil;
//  inherited DoRun;
//end;

procedure TFileSyncApplication.OnConsoleRun(Sender: TObject);
var
  text: string;
begin
  //执行encode加密密码
  if (ParamCount = 2) and ((HasOption('e','encode')) or (FindCmdLineSwitch ('encode',['/'],True))) then begin
      text := Params[ParamCount];
      WriteLn('The password is :' + EncodePassword(text));
  end
  else
      ShowHelp;;
end;

//constructor TFileSyncApplication.Create(AOwner: TComponent);
//begin
//  inherited Create(AOwner);
//  OnRun := @OnConsoleRun;
//end;

procedure TFileSyncApplication.ShowHelp;
begin
  inherited ShowHelp;
  if IsConsole then begin
     writeln('  -e --encode text  To encode password');
  end;
end;

end.

